/*
CCP 7.3
Given two lines on a Cartesian plane, determine whether the two lines would intersect.
*/
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <algorithm>
#include <functional>
#include <unordered_map>
//#include <tr1/thread>
using namespace std;

struct Point
{
	double x;
	double y;
	Point(int i,int j):x(i),y(j){}
};
struct Line
{
	Point p1,p2;
	Line(Point& pt1,Point& pt2):p1(pt1),p2(pt2){}
};

double CrossProduct(Point p1,Point p2,Point p3)
{
	return (p2.x-p1.x)*(p3.y-p1.y)-(p2.y-p1.y)*(p3.x-p1.x);
}
bool isIntersect(const Line& l1,const Line& l2)
{
	return max(l1.p1.x,l1.p2.x) >= min(l2.p1.x,l2.p2.x) &&
		   max(l2.p1.x,l2.p2.x) >= min(l1.p1.x,l1.p2.x) &&
		   max(l1.p1.y,l1.p2.y) >= min(l2.p1.y,l2.p2.y) &&
		   max(l2.p1.y,l2.p2.y)	>= min(l1.p1.y,l1.p2.y) &&
		   CrossProduct(l1.p1,l2.p1,l2.p2)*CrossProduct(l1.p2,l2.p1,l2.p2) <= 0 &&
		   CrossProduct(l2.p1,l1.p1,l1.p2)* CrossProduct(l2.p2,l1.p1,l1.p2) <=0;
}
int main(int argc, char const *argv[])
{
	Point p1(0,0);
	Point p2(2,2);
	Point p3(1,0);
	Point p4(1,1);
	Line l1(p1,p2);
	Line l2(p3,p4);
	cout<<isIntersect(l1,l2)<<endl;
	return 0;
}